<template>
  <div>
    <div class="content h278 mb10">
      <div
        class="s-tac s-d-flex s-ai-center s-jc-center h278"
        v-if="dataListShow"
      >
        <div>
          <img class="w190 h120" src="~@/assets/nodata.png" alt="" />
          <div style="color: #a8a8a8" class="fz14">暂无数据</div>
        </div>
      </div>
      <ul class="" v-else>
        <li
          class="s-d-flex s-ai-center content-li pt5 pb5 h40 lh40 w100p"
          style="border-bottom: 1px solid #ebedf0"
          v-for="(item, index) in dataList"
          :key="index"
        >
          <div class="s-d-flex s-jc-space-between w100p">
            <div style="display:flex;align-items:center">
              <img
                class="fz0 w16 mr5 t2"
                style="position: relative"
                :src="filter_alarm_type_img(item.type)"
                alt=""
              />
              <span v-if="userInfo.type == 'admin'">{{
                item.hospitalBaseName
              }}</span>
              <span v-else>{{
                item.hospitalDepartName
                  ? item.hospitalDepartName
                  : item.hospitalPlaceName
              }}</span>
            </div>
            <div>
              <span class="ml20">{{ filter_alarm_type(item.type) }}</span>
            </div>
            <div>
              {{ item.time }}
            </div>
          </div>

          <!-- <div class="pl15 eps-1 fz14">
            {{item.hospitalBaseName?item.hospitalBaseName:''}} {{item.time?item.time:''}} {{item.type | filter_alarm_type}}
          </div> -->
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import * as alarmRecordApi from "@/api/alarmRecord";
import { getUserInfo, setUserInfo } from "@/utils/auth";
export default {
  data() {
    return {
      dataList: [],
      dataListShow: false,
      userInfo: {},
    };
  },
  created() {
    this.handleGetDataList();
    this.userInfo = getUserInfo() ? JSON.parse(getUserInfo()) : {};
  },
  methods: {
    //获取列表数据
    handleGetDataList() {
      const params = {
        pageIndex: 1,
        pageSize: 5,
      };
      alarmRecordApi.warnBaseList(params).then((res) => {
        if (res && res.success) {
          this.dataList = res.data;
          if (res.data && res.data.length != 0) {
            this.dataListShow = false;
          } else {
            this.dataListShow = true;
          }
        }
      });
    },
      filter_alarm_type_img(val) {
  if (!val) return "";
  switch (val) {
    case "out_depot_time_red":
      return require('@/assets/time_red.png');
    case "out_depot_time_yellow":
      return require('@/assets/time_yellow.png');
    case "do_collect_weight_red":
      return require('@/assets/weight_red.png');
    case "do_collect_weight_yellow":
      return require('@/assets/weight_yellow.png');
    case "in_depot_weight_red":
      return require('@/assets/weight_red.png');
    case "in_depot_weight_yellow":
      return require('@/assets/weight_yellow.png');
    case "out_depot_weight_red":
      return require('@/assets/weight_red.png');
    case "out_depot_weight_yellow":
      return require('@/assets/weight_yellow.png');
    case "do_collect_time_red":
      return require('@/assets/time_red.png');
    case "do_collect_time_yellow":
      return require('@/assets/time_yellow.png');
    case "in_depot_time_red":
      return require('@/assets/time_red.png');
    case "in_depot_time_yellow":
      return require('@/assets/time_yellow.png');
  }
},
 filter_alarm_type(val) {
  if (!val) return "";
  switch (val) {
    case "out_depot_time_red":
      return "出库超时红色";
    case "out_depot_time_yellow":
      return "出库超时黄色";
    case "do_collect_weight_red":
      return "收集超重红色";
    case "do_collect_weight_yellow":
      return "收集超重黄色";
    case "in_depot_weight_red":
      return "入库超重红色";
    case "in_depot_weight_yellow":
      return "入库超重黄色";
    case "out_depot_weight_red":
      return "出库超重红色";
    case "out_depot_weight_yellow":
      return "出库超重黄色";
    case "do_collect_time_red":
      return "收集超时红色";
    case "do_collect_time_yellow":
      return "收集超时黄色";
    case "in_depot_time_red":
      return "入库超时红色";
    case "in_depot_time_yellow":
      return "入库超时黄色";
  }
},
    handleGoToNav() {
      this.$router.push({
        path: "/alarmInfo/alarmRecord",
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.flex-1 {
  flex: 1;
}
.content-li div {
  color: #909399;
}
</style>